package com.tanhua.model.vo;

import com.sun.org.apache.bcel.internal.generic.NEW;
import com.tanhua.model.pojo.UserInfo;
import com.tanhua.model.soul.SoulAppraise;
import com.tanhua.model.soul.SoulRecord;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReportVo implements Serializable {

    private String conclusion;
    private String cover;
    private List<Map<String,String>> dimensions;
    private List<Map> similarYou;

    public static ReportVo init(SoulAppraise appraise, SoulRecord record, List<UserInfo> userInfoList){
        ReportVo vo = new ReportVo();
        vo.setConclusion(appraise.getConclusion());
        vo.setCover(appraise.getCover());

        String outgoing = record.getOutgoing().toString()+"%";
        String judge = record.getJudge().toString()+"%";
        String abstractRate = record.getAbstractRate().toString()+"%";
        String logic = record.getLogic().toString()+"%";

        List<Map<String,String>> dimensionsList = new ArrayList<>();

        Map<String,String> map = new HashMap<>();
        map.put("key","外向");
        map.put("value",outgoing);
        dimensionsList.add(map);

        map = new HashMap<>();
        map.put("key","判断");
        map.put("value",judge);
        dimensionsList.add(map);

        map = new HashMap<>();
        map.put("key","抽象");
        map.put("value",abstractRate);
        dimensionsList.add(map);

        map = new HashMap<>();
        map.put("key","理性");
        map.put("value",logic);
        dimensionsList.add(map);
        vo.setDimensions(dimensionsList);

        if(!userInfoList.isEmpty()){
//            Map<Long, String> similarYouMap = userInfoList.stream().collect(Collectors.toMap(UserInfo::getId, UserInfo::getAvatar));
//            List<Map<Long,String>> similarYouList = new ArrayList<>();
//            similarYouList.add(similarYouMap);
//            vo.setSimilarYou(similarYouList);
            for (UserInfo userInfo : userInfoList) {
                Map userMap = new HashMap();
                userMap.put("id",userInfo.getId());
                userMap.put("avatar",userInfo.getAvatar());
                List<Map> similarYou = new ArrayList<>();
                similarYou.add(userMap);
                vo.setSimilarYou(similarYou);
            }
        }
        return vo;
    }
}
